package com.vvv.designpattern.singleton;

/**
 * @author vvv
 * @date 2023-11-13 09 20
 * discription 懒汉式
 * 没有线程安全问题，但是锁的范围太大了
 */
public class Singleton02 {

    private static Singleton02 singleton02;

    private Singleton02(){}

    public static synchronized Singleton02 getInstance() {
        if (singleton02 != null) {
            return singleton02;
        }
        singleton02 = new Singleton02();
        return singleton02;
    }

    public static void main(String[] args) {

    }
}
